<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP, MagicHash, UnboxedTuples #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# OPTIONS_HADDOCK not-home #-}</span><span>
</span><span id="line-3"></span><span>
</span><span id="line-4"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- Module      : Data.Text.Internal.Unsafe</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- Copyright   : (c) 2009, 2010, 2011 Bryan O'Sullivan</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- License     : BSD-style</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Maintainer  : bos@serpentine.com</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Stability   : experimental</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Portability : portable</span><span>
</span><span id="line-11"></span><span class="hs-comment">--</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- /Warning/: this is an internal module, and does not have a stable</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- API or name. Functions in this module may not check or enforce</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- preconditions expected by public modules. Use at your own risk!</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- A module containing /unsafe/ operations, for /very very careful/ use</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- in /heavily tested/ code.</span><span>
</span><span id="line-18"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Text.Internal.Unsafe</span><span>
</span><span id="line-19"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-20"></span><span>      </span><span class="annot"><a href="Data.Text.Internal.Unsafe.html#inlineInterleaveST"><span class="hs-identifier">inlineInterleaveST</span></a></span><span>
</span><span id="line-21"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.Unsafe.html#inlinePerformIO"><span class="hs-identifier">inlinePerformIO</span></a></span><span>
</span><span id="line-22"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#"><span class="hs-identifier">GHC.ST</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier">ST</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#"><span class="hs-identifier">GHC.IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier">IO</span></a></span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier">IO</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#"><span class="hs-identifier">GHC.Base</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#realWorld%23"><span class="hs-identifier">realWorld#</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-comment">-- | Just like unsafePerformIO, but we inline it. Big performance gains as</span><span>
</span><span id="line-29"></span><span class="hs-comment">-- it exposes lots of things to further inlining. /Very unsafe/. In</span><span>
</span><span id="line-30"></span><span class="hs-comment">-- particular, you should do no memory allocation inside an</span><span>
</span><span id="line-31"></span><span class="hs-comment">-- 'inlinePerformIO' block.</span><span>
</span><span id="line-32"></span><span class="hs-comment">--</span><span>
</span><span id="line-33"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Internal.Unsafe.html#inlinePerformIO"><span class="hs-pragma hs-type">inlinePerformIO</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-34"></span><span id="local-6989586621679104522"><span class="annot"><a href="Data.Text.Internal.Unsafe.html#inlinePerformIO"><span class="hs-identifier hs-type">inlinePerformIO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104522"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679104522"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-35"></span><span id="inlinePerformIO"><span class="annot"><span class="annottext">inlinePerformIO :: forall a. IO a -&gt; a
</span><a href="Data.Text.Internal.Unsafe.html#inlinePerformIO"><span class="hs-identifier hs-var hs-var">inlinePerformIO</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span id="local-6989586621679104507"><span class="annot"><span class="annottext">State# RealWorld -&gt; (# State# RealWorld, a #)
</span><a href="#local-6989586621679104507"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">State# RealWorld -&gt; (# State# RealWorld, a #)
</span><a href="#local-6989586621679104507"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="../../ghc-prim/src/GHC.Prim.html#realWorld%23"><span class="hs-identifier hs-var">realWorld#</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679104506"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104506"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104506"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="hs-comment">-- | Allow an 'ST' computation to be deferred lazily. When passed an</span><span>
</span><span id="line-38"></span><span class="hs-comment">-- action of type 'ST' @s@ @a@, the action will only be performed when</span><span>
</span><span id="line-39"></span><span class="hs-comment">-- the value of @a@ is demanded.</span><span>
</span><span id="line-40"></span><span class="hs-comment">--</span><span>
</span><span id="line-41"></span><span class="hs-comment">-- This function is identical to the normal unsafeInterleaveST, but is</span><span>
</span><span id="line-42"></span><span class="hs-comment">-- inlined and hence faster.</span><span>
</span><span id="line-43"></span><span class="hs-comment">--</span><span>
</span><span id="line-44"></span><span class="hs-comment">-- /Note/: This operation is highly unsafe, as it can introduce</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- externally visible non-determinism into an 'ST' action.</span><span>
</span><span id="line-46"></span><span id="local-6989586621679104519"><span id="local-6989586621679104520"><span class="annot"><a href="Data.Text.Internal.Unsafe.html#inlineInterleaveST"><span class="hs-identifier hs-type">inlineInterleaveST</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104520"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104519"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104520"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104519"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-47"></span><span id="inlineInterleaveST"><span class="annot"><span class="annottext">inlineInterleaveST :: forall s a. ST s a -&gt; ST s a
</span><a href="Data.Text.Internal.Unsafe.html#inlineInterleaveST"><span class="hs-identifier hs-var hs-var">inlineInterleaveST</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-type">ST</span></a></span><span> </span><span id="local-6989586621679104504"><span class="annot"><span class="annottext">STRep s a
</span><a href="#local-6989586621679104504"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">STRep s a -&gt; ST s a
forall s a. STRep s a -&gt; ST s a
</span><a href="../../base/src/GHC.ST.html#ST"><span class="hs-identifier hs-var">ST</span></a></span><span> </span><span class="annot"><span class="annottext">(STRep s a -&gt; ST s a) -&gt; STRep s a -&gt; ST s a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span id="local-6989586621679104503"><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679104503"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-48"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679104502"><span class="annot"><span class="annottext">r :: a
</span><a href="#local-6989586621679104502"><span class="hs-identifier hs-var hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">STRep s a
</span><a href="#local-6989586621679104504"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679104503"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# s
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679104501"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104501"><span class="hs-identifier hs-var">res</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104501"><span class="hs-identifier hs-var">res</span></a></span><span> </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# s
</span><a href="#local-6989586621679104503"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104502"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">#)</span><span>
</span><span id="line-49"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Internal.Unsafe.html#inlineInterleaveST"><span class="hs-pragma hs-type">inlineInterleaveST</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-50"></span></pre></body></html>